package org.wmq.protobuf;

import com.alibaba.fastjson.JSON;

import java.io.IOException;

/**
 * 主类，用于演示ProtobufConverter工具类的使用
 */
public class Main {
    public static void main(String[] args) {
        Message message = Message.builder().name("WangMingQuan")
                .clazz("System")
                .id(2023302131033L)
                .compulsory(true).build();
        byte[] protobufBytes = ProtobufConverter.encodeMessage(message);
        byte[] jsonBytes = JSON.toJSONString(message).getBytes();
        System.out.println("Protobuf字节数: " + protobufBytes.length);
        System.out.println("JSON字节数: " + jsonBytes.length);
        System.out.println(protobufBytes.length/jsonBytes.length);
    }
}
